<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>意见反馈 - 管理后台</title>
    <link rel="stylesheet" href="/static/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/public.css" media="all"/>
</head>
<body class="childrenBody">
<div class="layui-col-md12">
    <blockquote class="layui-elem-quote title">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0);">系统设置</a>
            <a><cite>意见反馈</cite></a>
        </span>
    </blockquote>
    <table id="guestBookList" lay-filter="guestBookList" class="layui-table"></table>
    <script type="text/html" id="guest_bookListTBar">
        <a class="layui-btn layui-btn-xs" lay-event="delete">删除</a>
    </script>
    <script type="text/html" id="guestBookImage">
        {{# layui.each(d.images.split(','), function(index, item){ }}
        {{# if(item != ''){ }}
        <img src="/{{ item }}" style="height:30px;"/>
        {{#  } }}
        {{#  }); }}
    </script>
</div>
<script src="/static/layui.js"></script>
<script>
    layui.use(['element', 'jquery', 'layer', 'table', 'form'], function () {
        var layer = layui.layer,
            $ = layui.jquery,
            table = layui.table;
        var tableIns = table.render({
            elem: '#guestBookList',
            url: '{:url("system/guestBook")}',
            cellMinWidth: 95,
            id: "guestBookListTable",
            cols: [[
                {field: 'phone', title: '联系电话', width: 200, align: "center"},
                {field: 'content', title: '内容', minWidth: 100, align: "center"},
                {field: 'images', templet: '#guestBookImage', title: '图片', minWidth: 100, align: "center"},
                {field: 'create_time', title: '提交时间', minWidth: 100, align: "center"},
                {title: '操作', templet: '#guest_bookListTBar', fixed:'right', width:150, align:'center'}
            ]]
        });
        $('.childrenBody').on('click','img',function(){
            var that = this;
            var img = new Array;
            var index = 0;
            $(this).parent().find('img').each(function(i,e){
                if($(e).attr('src') == $(that).attr('src')){
                    index = i;
                }
                img.push({src:$(e).attr('src')});
            });
            layer.photos({
                photos: {data:img,start:index},
                start: index,
                anim: 5
            });
        });
        table.on('tool(guestBookList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'delete') {
                layer.open({
                    content:'确定删除该留言么？删除后不可恢复',
                    btn: ['确定', '取消'],
                    yes: function(){
                        var index = layer.load(1);
                        $.get('{:url("system/deleteGuestBook")}?id=' + data.guest_book_id,function (data) {
                            if(data.code == 0){
                                layer.close(index);
                                layer.msg(data.msg, {
                                    time: 3000,
                                    icon:1
                                }, function(){
                                    window.location.reload();
                                });
                            }else{
                                layer.close(index);
                                layer.msg(data.msg,{icon:5,shift:6});
                            }
                        });
                        return true;
                    },
                    btn2: function(){
                        return true;
                    }
                });
            }
        });
    });
</script>
</body>
</html>